import {encodeSearchParams} from "@/common/utils/utils.js";

const PREFIX = '/admin/file'
import request from '@/request/request.js'

/**
 * 获取所有文件列表
 * @returns {Promise | Promise<unknown> | *}
 * @param searchData
 */
export const getFile = (searchData) => request(`${PREFIX}/getFile?${encodeSearchParams(searchData)}`)

/**
 * 分片上传
 * @param data
 * @returns {*}
 */
export const uploadChunkList = (data) => request(`${PREFIX}/uploadChunk`, data, 'post')

/**
 * 检查文件是否上传过
 * @param md5 文件的MD5值
 * @returns {*}
 */
export const checkFile = (md5) => request(`${PREFIX}/checkFile/${md5}`)

/**
 * 删除文件
 * @param id 文件的ID
 * @returns {Promise | Promise<unknown> | *}
 */
export const deleteFile = (id) => request(`${PREFIX}/deleteFile/${id}`)
